package cn.cdutetc.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "LoginServlet", value = "/Login")
public class LoginServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username=request.getParameter("username");
        String pwd=request.getParameter("password");
        String[] hobbies=request.getParameterValues("hobby");
        HttpSession session= request.getSession(true);
        session.setAttribute("user",username);

        //转向,地址栏不会发生改变      是一次request请求
        //重定向，地址栏会变成重定向的地址      是两次request请求
        request.getRequestDispatcher("index.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
